#pragma once

#include "commons.hxx"

#ifndef MAX_OBJECT_NAME_LENGTH
#define MAX_OBJECT_NAME_LENGTH 512
#endif

#define CUST_ERROR_SCH_TASK_NO_RA    (EMH_USER_error_base + 901)

#define REGISTER_HANDLERS(site,decision,args) info_syslog("*Register handlers, from: '%s.dll(.so)'...\n",TO_STRING(site));CHECK(OUR_register_handlers(decision,args))
#define REGISTER_ACTION_HANDLER(name,desc,func) info_syslog("@Action handler - %s: %s\n",name,desc);CHECK(EPM_register_action_handler(name,desc,func))
#define REGISTER_RULE_HANDLER(name,desc,func) info_syslog("@Rule handler - %s: %s\n",name,desc);CHECK(EPM_register_rule_handler(name,desc,func))

/// <summary>
/// 定义 Action Handler 结构
/// </summary>
typedef struct tag_action_handler {
	const char* name;
	const char* desc;
	EPM_action_handler_t func;
} OUR_action_handler;

/// <summary>
/// 定义 Rule Handler 结构
/// </summary>
typedef struct tag_rule_handler {
	const char* name;
	const char* desc;
	EPM_rule_handler_t func;
} OUR_rule_handler;

/// <summary>
/// 注册 Handler 方法
/// </summary>
/// <param name="decision"></param>
/// <param name="args"></param>
/// <returns>是否注册成功</returns>
int OUR_register_handlers(int* decision, va_list args);
